<template>
    <div class="youke">
        <Navs left></Navs>
        <Main>
            <template v-if="ret.title">
                <van-cell class="body">
                    <p class="title">{{ret.title}}</p>
                    <p class="time">发布时间：{{ret.time}}</p>
                    <p v-html="ret.detail"></p>
                </van-cell>
            </template>
            <template v-else>
                <nolist/>
            </template>
        </Main>
    </div>
</template>

<script type="text/ecmascript-6">
   import {news} from '@/api'
   import nolist from '@/components/common/nolist'
    export default {
        //接收父级传递的参数
        props: [],
        //监听数据变化
        watch: {},
        data() {
            return {
                ret:{
                    time:'',
                    title:'',
                    detail:''
                }
            }
        },
//实例初始化之前触发事件
        beforeCreate() {
        },
//实例化之后触发事件
        created() {
        },
//实时监控data参数数据变化
        computed: {},
        //模板组件
        components: {
            nolist
        },
//执行方法
        methods: {
            getlist(){
                news.newsdetail({id:this.$route.query.id}).then(res=>{
                    if(res.code==1000){
                        this.ret.time=res.result.time;
                         this.ret.title=res.result.title
                          this.ret.detail=res.result.content
                    }
                })
            }
        },
        mounted() {
            if(this.$route.query.id){
                this.getlist()
            }
           
            // console.log(this.$route.query);
        },
//路由退出时候调用
        //beforeRouteLeave(to, from, next){next()}
    }
</script>

<style scoped lang="less">
    .title{
        font-size: 1.1rem;
    }
    .time{
        margin-top: 0.5rem;
        font-size: 12px;
        color: #AFAFAF;
    }
</style>
